﻿@using XStudio.WebFramework.Mvc.Extensions
@model IList<XStudio.Framework.Support.Entity.User.EmployeeEntity>
<div style="margin: 10px; padding: 5px;">
    <div class="tip-alert-box" id="receiveUse">
        <p>
            <strong>〓 选中员工(@(Model.Count)个)：</strong></p>
        <p>
            @foreach (var item in Model)
            {
                <span class="btn-user">@item.EmployeeName</span>
            }
        </p>
    </div>
    <form name="frmResetInstitution" id="frmResetInstitution" method="post" action="@Request.Url">
    <table class="tbl-input" cellspacing="0" style="width: 100%;">
        <colgroup>
            <col style="width: 100px;" />
            <col class="w4" />
            <col />
        </colgroup>
        <tbody>
            <tr>
                <th scope="row">
                    转到区域：
                </th>
                <td>
                    @Html.InstitutionDropDownList("InstitutionID", XStudio.WebFramework.Support.UserAppI.CurrentUser.InstitutionID, "-1", "请选择区域", "-1", new { style = "width:200px" })
                </td>
                <td class="slight">
                    <span class="btn-infomust">必选项。</span>
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    <div class="lineSolid" style="margin: 5px;">
                    </div>
                    <div style="padding: 15px; text-align: center">
                        <input type="button" value="保存" onclick="Reset.Save(this)" class="btn-8" />
                        <span>&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <input type="button" value="返回" onclick="Reset.Back(this)" class="btn-8" />
                    </div>
                </td>
            </tr>
        </tbody>
    </table>
    </form>
</div>
<script type="text/javascript">
    var Reset = {};
    jQuery.validator.addMethod('SelectNone', function (value, element) {
        return this.optional(element) || (parseFloat(value) != -1);
    }, "请先选择内容！"
    );

    $(document).ready(function () {
        //表单验证
        var v = $("#frmResetInstitution").validate({
            focusInvalid: true,
            rules: {
                InstitutionID: { SelectNone: true }
            },
            messages: {
                InstitutionID: { SelectNone: "请选择转到区域！" }
            },
            errorPlacement: function (error, element) {
                var objError = $(element.parents("td").next("td"));
                objError.removeClass("msg_infomust");
                objError.html(error);
            },
            success: function (element) {
                element.html("正确").addClass("tip-success");
            }
        });
    });

    Reset.Save = function (e) {
        var frm = $(e).parents("form");
        if (!$(frm).valid())
            return false;

        InstitutionName = $("#InstitutionID").find(":selected").text();
        if (!confirm("确认要将选中的管理员转移至【" + InstitutionName + "】吗？"))
            return;

        $.ajax({
            url: $(frm).attr("action"),
            data: $(frm).serialize(),
            type: "Post",
            error: function (request) {
                alert('保存出错，请重试！');
            },
            success: function (data) {
                if (data.IsOK) {
                    //刷新列表
                    $('#tbList').datagrid('reload');
                    //关闭窗口
                    $.closeWin(e);
                }
                else
                    alert(data.Description);
            }
        });
    }
    Reset.Back = function (e) {
        $.closeWin(e);
    }
</script>
